package com.longteng.java.web.transaction;

import org.springframework.stereotype.Component;
import org.springframework.transaction.support.TransactionTemplate;

import javax.annotation.Resource;

/**
 * Created by tianqing.wang
 * DATE : 2018/4/22
 * TIME : 上午12:09
 * PROJECT : web-lesson
 * PACKAGE : com.longteng.java.web.transaction
 *
 * @author <a href="mailto:celeskyking@163.com">tianqing.wang</a>
 */
@Component
public class TransactionDemo {

    @Resource
    private TransactionTemplate transactionTemplate;


    public void doSomething(){
        transactionTemplate.execute(transactionStatus -> {
            //进行数据库操作
            return "success";
        });
    }
}
